package com.example.nfctagcommons.managers;

import java.util.HashMap;
import java.util.List;

import android.app.Activity;

import com.example.nfctagcommons.classes.VigilancePoint;
import com.example.nfctagcommons.exceptions.ConnectivityException;
import com.example.nfctagcommons.server.ServerConnector;

public class LocalManager {
	private static List<VigilancePoint> localesList;
	private static HashMap<String, VigilancePoint> localesHashMap;
	public static List<VigilancePoint> getAllLocals(Activity activity) throws ConnectivityException{
		if (localesList == null){
			localesList = ServerConnector.getAllLocals(activity);
		}
		return localesList;
	}
	
	public static HashMap<String, VigilancePoint> getAllLocalsAsMap(Activity activity) throws ConnectivityException{
		if (localesHashMap == null){
			List<VigilancePoint> list = getAllLocals(activity);
			localesHashMap = new HashMap<String, VigilancePoint>();
			for (VigilancePoint local : list){
				localesHashMap.put(local.getLocalId(), local);
			}
		}
		return localesHashMap;
	}
}
